#pragma once
#define BUF_SIZE 0x100
#define MAX_CITY_COUNT 30
#include<stdbool.h>
struct __arc__
{
	unsigned int to;
	unsigned int distance;
	struct __arc__* next;
};

struct __node__
{
	char name[BUF_SIZE];
	struct __arc__* first_arc;
	int in;
};

struct __graph__ {
	struct  __node__ cities[MAX_CITY_COUNT];
	int city_count;

}GRAPH;

typedef struct __arc__ GraphArc;
typedef struct __node__ GraphNode;

//#define ASSERT_WARNING(expr,msg) if(!expr){\
//	fprintf(stderr,"%s\n",msg);\
//	}

#define ASSERT_ABORT(expr,msg) if(!(expr)){\
	fprintf(stderr,"%s\n",(msg));\
	system("pause");\
	return false;\
}
#define ASSERT_RETRY(expr,msg,jump_out) if(!(expr)){\
	fprintf(stderr,"%s\n",(msg));\
	system("pause");\
	if(jump_out)break;\
	else continue;\
}
#define CHOICE_VALID(expr) ASSERT_ABORT(expr,"无效选择")

extern int city_count;


int initGraph();

bool addEdge(int first, int second, int distance);
unsigned int getDistance(unsigned int first, unsigned int second);
unsigned int* shortest_distance_DIJ(int v0);
int DFS(int v);